Use Django ORM as standalone [closed]
        Posted  
        
            by KeyboardInterrupt
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by KeyboardInterrupt
        
        
        
        Published on 2009-06-02T02:58:16Z
        Indexed on 
            2010/04/15
            9:23 UTC
        
        
        Read the original article
        Hit count: 336
        
Possible Duplicates:
Use only some parts of Django?
Using only the DB part of Django
I want to use the Django ORM as standalone. Despite an hour of searching Google, I'm still left with several questions:
- Does it require me to set up my Python project with a setting.py, /myApp/ directory, and modules.py file?
- Can I create a new models.pyand runsyncdbto have it automatically setup the tables and relationships or can I only use models from existing Django projects?
- There seems to be a lot of questions regarding PYTHONPATH. If you're not calling existing models is this needed?
I guess the easiest thing would be for someone to just post a basic template or walkthrough of the process, clarifying the organization of the files e.g.:
db/
   __init__.py
   settings.py
   myScript.py
orm/
   __init__.py
   models.py
And the basic essentials:
# settings.py
from django.conf import settings
settings.configure(
     DATABASE_ENGINE   = "postgresql_psycopg2",
     DATABASE_HOST     = "localhost",
     DATABASE_NAME     = "dbName",
     DATABASE_USER     = "user",
     DATABASE_PASSWORD = "pass",
     DATABASE_PORT     = "5432"
)
# orm/models.py
# ...
# myScript.py
# import models..
And whether you need to run something like: django-admin.py inspectdb ...
(Oh, I'm running Windows if that changes anything regarding command-line arguments.).
© Stack Overflow or respective owner